package com.neusoft.mapper;

import com.github.pagehelper.Page;
import com.neusoft.domain.Food;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FoodMapper {
    @Select("select count(*) from food where category_id=#{categoryId} " )
    Integer selectFoodByCategoryId(Integer categoryId);

    Page<Food>findFoodByPageAndShopId(@Param("foodName") String foodName, @Param("shopId") Integer shopId);
    @Update("update food set food_name=#{foodName},stock=#{stock},status=#{status},food_price=#{foodPrice},shop_id=#{shopId},food_img=#{foodImg},remarks=#{remarks},recommend=#{recommend},category_id=#{categoryId},hot=#{hot},food_id=#{foodId},food_explain=#{foodExplain} where food_id=#{foodId}")
    void updateFood(Food food);
    @Insert("insert into food(food_name,stock,status,food_price,shop_id,food_img,remarks,recommend,category_id,hot,food_id,food_explain) values(#{foodName},#{stock},#{status},#{foodPrice},#{shopId},#{foodImg},#{remarks},#{recommend},#{categoryId},#{hot},#{foodId},#{foodExplain})")
    void addFood(Food food);
    @Update("update food set status=#{status} where food_id=#{foodId}")
    void changeFoodStatus(@Param("foodId") Integer foodId,@Param("status") Integer status);

    Food getFoodById(Integer foodId);
    @Update("update food set recommend=#{recommend} where food_id=#{foodId}")
    void recommendFood(@Param("foodId") Integer foodId,@Param("recommend") Integer recommend);
    @Update("update food set hot=#{newHot} where food_id=#{foodId}")
    void hotFood(@Param("foodId") Integer foodId, @Param("newHot") Integer newHot);
}
